package com.zmc.search.exception.handler;

import com.zmc.common.utils.R;
import com.zmc.search.exception.EsRequestException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author：zmc
 * @Date：2024/11/11 15:27
 */

@ControllerAdvice
@ResponseBody
public class EsExceptionHandler {

    @ExceptionHandler(value = EsRequestException.class)
    public R esRequestExceptionHandler(EsRequestException exception) {
        return R.error(exception.getErrorCode().getCode(), exception.getMessage());
    }


}
